home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_08
/
1008014b
< prev
next >
Wrap
Text File
|
1992-06-10
|
441b
|
22 lines
Listing 4 -- getenv.c
* getenv function -- in-memory version */
#include <stdlib.h>
#include <string.h>
#include "yfuns.h"
char *(getenv)(const char *name)
{ /* search environment list for named entry */
const char *s;
size_t n = strlen(name);
for (s = _Envp; *s; s += strlen(s) + 1)
{ /* look for name match */
if (!strncmp(s, name, n) && s[n] == '=')
return ((char *)&s[n + 1]);
}
return (NULL);
}